<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="/WebFinalProject/css/FinalProjectCSS.css" rel="stylesheet"
	type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="table.js"></script>
<script type="text/javascript" src="js/MasterJS.js"></script>
<script type="text/javascript">
	function manage(task, id) {
		document.forms[0].task.value = task;
		document.forms[0].groupClassId.value = id;
		var r = false;
		if(task == 'deleteGroupClass'){
			r = confirm('Are you sure want to delete?');
		}else{
			//r = confirm('Are you sure want to update?');
			r = true;
		}
		if(r == true){
			document.forms[0].submit();
		}
	}
	 
	function detail(id, name) {
		document.forms[0].groupClassId.value = id;
		//document.forms[0].task.value = 'groupClassDetail';
		//document.forms[0].submit();
		var task = 'groupClassDetail';
		$.ajax({
            type: "POST",
            url: "/WebFinalProject/Master.do",
            data: "groupClassId=" + id + "&task=" + task,
            success: function(response){
                $('#grClassDetail').html("<div class='formListStyle'><b>" + name + " Detail</b></div>" + response);
            },
            error: function(e){
                alert('Error: ' + e);
            }
        });
	}
	
	function searchByParam() {
		document.forms[0].elements['paramClassName'].value = document.getElementById('searchClassName').value;
		document.forms[0].elements['task'].value='manageGroupClass';
		document.forms[0].submit();
	}
	
	function setDisplay() {
		document.getElementById('searchClassName').value = document.forms[0].elements['paramClassName'].value;
		if(document.forms[0].elements['paramClassName'].value != ''){
			document.getElementById('searchClassName').focus(); 
		}
	}
</script>
<title>Manage Group Class</title>
</head>
<body onload="javascript:setDisplay();">
	<%
		if(session.getAttribute("result") != null)
		{
			String message = session.getAttribute("result").toString();
			%>
				<script type="text/javascript">
					window.alert('<%=message%>');
				</script>
			<%
			session.removeAttribute("result");
		}
	%>
	<center>
		<table width="100%" class="bodyTable boxShadow">

			<!-- Header -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>

			<!-- Content -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td align="left" class="headerBox blueBackground">Setting > Manage Group Class</td>
			</tr>
			<tr>
				<td align="center" class="contentStyle"><br> 
				
					<html:form action="/Master" method="post" enctype="multipart/form-data">
						<html:hidden name="schoolForm" property="task" />
						<html:hidden name="schoolForm" property="groupClassId"/>
						<html:hidden name="schoolForm" property="paramClassName"/>
<%-- 						<html:hidden property="id" /> --%>
						<%-- 					<html:hidden property="idUpdate"/> --%>
						<br />
						<table width="95%" border="0" align="center" class="boxShadow  example table-autosort table-autofilter  table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount" id="t1">							
							<thead>
								<tr class="headerBox formHeaderBackground">
									<th colspan="2" align="center" class="formListStyle filterable table-sortable:default">Group Class Name</th>
									<th align="center" class="formListStyle filterable table-sortable:default">Weight</th>
									<th colspan="2"></th>
								</tr>
								<tr>
									<th colspan="2" class="formListStyle"><input type="text" id="searchClassName" class="textStretch" onkeyup="javascript:searchByParam();"/></th>
									<th colspan="3"></th>
								</tr>
							</thead>
							<tbody>
								<logic:notEmpty name="schoolForm" property="groupClassList">
									<logic:iterate id="listData" name="schoolForm" property="groupClassList">
										<tr class="formListBackground">
											<td colspan="2" class="formListStyle leftAlign">
<%-- 												<a href="javascript:detail('<bean:write name="listData" property="groupClassId"/>')"> --%>
												<bean:write name="listData" property="groupClassName" />
<!-- 												</a> -->
											</td>
											<td align="center" class="formListStyle" style="width:15%;">
												<bean:write name="listData" property="groupClassWeight"></bean:write>
											</td>
											<td colspan="2" align="right" class="formListStyle" style="width:15%;">
<%-- 												<input type="button" class="buttonStyle" value="Update" onclick="javascript:manage('updateGroupClass','<bean:write name="listData" property="groupClassId"/>');"> --%>
<%-- 												<input type="button" class="buttonStyle" value="Delete" onclick="javascript:manage('deleteGroupClass','<bean:write name="listData" property="groupClassId"/>');">												 --%>
												<img src="images/detailButton.png" title="view detail" style="cursor: pointer;" onclick="javascript:detail('<bean:write name="listData" property="groupClassId"/>', '<bean:write name="listData" property="groupClassName" />');"/>
												&nbsp;
												<img src="images/editButton.png" title="edit" style="cursor: pointer;" onclick="javascript:manage('updateGroupClass','<bean:write name="listData" property="groupClassId"/>');"/>
												&nbsp;
												<img src="images/deleteButton.png" title="delete" style="cursor: pointer;" onclick="javascript:manage('deleteGroupClass','<bean:write name="listData" property="groupClassId"/>');"/>
											</td>
										</tr>
									</logic:iterate>
								</logic:notEmpty>
								<logic:empty name="schoolForm" property="groupClassList">
									<tr class="formListBackground">
										<td colspan="5" class="formListStyle" align="center">Data is not found</td>
									</tr>
								</logic:empty>
							</tbody>							
							<tfoot>
								<tr class="headerBox formHeaderBackground">
									<td width="80px" class="table-page:previous formListStyle leftAlign" style="cursor:pointer;">&lt;&lt; Previous</td>
									<td colspan="3" style="text-align:center; vertical-align: middle;" colspan="2">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td>
									<td width="55px" align="right" class="table-page:next formListStyle rightAlign" style="cursor:pointer;">Next &gt;&gt;</td>
								</tr>	
								<tr>
<!-- 									<td colspan="4" align="center" style="vertical-align: middle; padding: 5px 7px;"> -->
<!-- 										<input type="button" value="Insert" class="buttonStyle" onclick="javascript:flyToInsert()" /> -->
<!-- 									</td> -->
									<td colspan="5" id="insertButton" title="add new" align="center" class="greyBackground">						
									<div class="insertButtonGridStyle" onclick="javascript:flyToPage('insertGroupClass');">
										<table>
											<tr>
												<td class="formListStyle"><img src="images/addButton.png"></td>
												<td class="formListStyle"><b>Add New Group Class</b></td>
											</tr>
										</table>
									</div>									
								</td>
								</tr>
<!-- 								<tr> -->
<!-- 									<td class="table-page:previous" style="cursor: pointer; padding: 5px 7px;">&lt; &lt; Previous</td> -->
<!-- 									<td colspan="4" style="text-align: center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td> -->
<!-- 									<td class="table-page:next" style="cursor: pointer; vertical-align: middle; padding: 5px 7px;">Next &gt; &gt;</td> -->
<!-- 								</tr> -->
								<tr>
									<td class="headerBox formHeaderBackground" colspan="5" align="center" style="padding:5px 7px;">									
										<span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s)
									</td>
								</tr>
							</tfoot>
						</table><br>
						<div id="grClassDetail"></div>						
					</html:form><br>
				</td>
			</tr>

			<!-- Footer -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy;
					OME. 2014. All Rights Reserved.</td>
			</tr>
		</table>
	</center>
</body>
</html>